﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FrameWork.Plugin;
using FrameWork.Setting;
using FrameWork.Log;
using System.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel;
using FrameWork.Output;
using System.Windows.Forms;
using ScreenMonitor.ServerLib.Plugin;

namespace PluginTest
{
    [SettingParentDefine]
    public class TestPlugin:LogableClassBase,IServerPlugin
    {

        
        private string TextV;
        /// <summary>
        /// 测试文本
        /// </summary>
        [SettingItemDefine(SettingValueType.String,"HelloWord")]
        [Browsable(true)]
        [DisplayName("文本")]
        [Description("设置插件窗口中显示的文本")]
        public string Text
        {
            get { return TextV; }
            set 
            {
                TextV = value;
                PluginObjects.PluginWnd.textBox1.Text = TextV;
                PrintLog(LogType.Info, "文本改变");
            }
        }
        

        public string GetPluginName()
        {
            return "TestPlugin";
        }

        public Guid GetPluginGuid()
        {
            return new Guid("49E8F690-74F9-47C3-ACFA-16A8A95C7A00");
        }

        public string GetPluginDescription()
        {
            return "Test";
        }

        public List<FrameWork.Setting.SettingEditorItem> GetSettingEditors()
        {
            List<SettingEditorItem> EditorList=new List<SettingEditorItem>();
            EditorList.Add(new SettingPropertyEditorItem(@"测试插件\显示",this,this.GetType()));
            return EditorList;
        }

        public System.Windows.Forms.Form GetPluginWindow()
        {
            return PluginObjects.PluginWnd;
        }

        public IEnumerable<FrameWork.Output.OutputCollectorBase> GetOutputCollectors()
        {
            List<OutputCollectorBase> List = new List<OutputCollectorBase>();
            List.Add(PluginObjects.TestPluginOutputCollector);
            return List;
        }

        public bool Enable()
        {
            base.PrintLog(LogType.Info, "测试插件已启用！");
            return true;
        }

        public bool Disable()
        {
            base.PrintLog(LogType.Info, "测试插件已禁用！");
            return true;
        }

        public bool Init()
        {
            base.PrintLog(LogType.Info, "测试插件初始化...");
            return true;
        }


        public void SetMenu(System.Windows.Forms.MenuStrip MainMenuStrip)
        {
            ToolStripItem[] MenuItems=MainMenuStrip.Items.Find("ManagerMenu",false);
            if(MenuItems.Count()>0)
            {
                ToolStripItem Tools = MenuItems[0];
                MainMenuStrip.Items.Insert(MainMenuStrip.Items.IndexOf(Tools), PluginObjects.PluginWnd.TestPluginToolStripMenuItem);
            }
        }

        public List<string> GetCommands()
        {
            return new List<string>();
        }

        public void RunCommand(string Command, byte[] Data)
        {
            return;
        }
    }
}
